package com.ruoyi.web.controller.seal;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.seal.domain.SealType;
import com.ruoyi.seal.service.ISealTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用印类型Controller
 *
 * @author ruoyi
 * @date 2022-08-30
 */
@RestController
@RequestMapping("/seal/sealType")
public class SealTypeController extends BaseController
{
    @Autowired
    private ISealTypeService sealTypeService;

    /**
     * 查询用印类型列表
     */
    @PreAuthorize("@ss.hasPermi('seal:sealType:list')")
    @GetMapping("/list")
    public TableDataInfo list(SealType sealType)
    {
        startPage();
        List<SealType> list = sealTypeService.selectSealTypeList(sealType);
        return getDataTable(list);
    }

    /**
     * 导出用印类型列表
     */
    @PreAuthorize("@ss.hasPermi('seal:sealType:export')")
    @Log(title = "用印类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SealType sealType)
    {
        List<SealType> list = sealTypeService.selectSealTypeList(sealType);
        ExcelUtil<SealType> util = new ExcelUtil<SealType>(SealType.class);
        util.exportExcel(response, list, "用印类型数据");
    }

    /**
     * 获取用印类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('seal:sealType:query')")
    @GetMapping(value = "/{sealTypeId}")
    public AjaxResult getInfo(@PathVariable("sealTypeId") Long sealTypeId)
    {
        return AjaxResult.success(sealTypeService.selectSealTypeBySealTypeId(sealTypeId));
    }

    /**
     * 新增用印类型
     */
    @PreAuthorize("@ss.hasPermi('seal:sealType:add')")
    @Log(title = "用印类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SealType sealType)
    {
        return toAjax(sealTypeService.insertSealType(sealType));
    }

    /**
     * 修改用印类型
     */
    @PreAuthorize("@ss.hasPermi('seal:sealType:edit')")
    @Log(title = "用印类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SealType sealType)
    {
        return toAjax(sealTypeService.updateSealType(sealType));
    }

   /* *
     * 删除用印类型
     */
    @PreAuthorize("@ss.hasPermi('seal:sealType:remove')")
    @Log(title = "用印类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{sealTypeIds}")
    public AjaxResult remove(@PathVariable Long[] sealTypeIds)
    {
        return toAjax(sealTypeService.deleteSealTypeBySealTypeIds(sealTypeIds));
    }
}
